//
// Created by Jisam on 2024/8/18 19:26.
// Solution of  构造故事
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

#define endl "\n"
#define PSI pair<string,int>
#define PII pair<int,int>
#define PDI pair<double,int>
#define PDD pair<double,double>
#define VVI vector<vector<int>>
#define VI vector<int>
#define VS vector<string>

#define PQLI priority_queue<int, vector<int>, less<int>>
#define PQGI priority_queue<int, vector<int>, greater<int>>
#define code_by_jisam ios::sync_with_stdio(false),cin.tie(nullptr)
using namespace std;
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
bool judge(int a,int b,int c){
    return a + b > c && a + c > b && b + c > a;
}
void solution() {
    int n;
    cin >> n;
    VI a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end(), [&](int a, int b) { return a > b; });
    i64 ans =  -1 ;
    int flag = 0;
    for (int i = 0; i < n && flag == 0; i++) {
        for (int j = i + 1; j < n && flag == 0; j++) {
            for (int k = j + j; k < n; k++) {
                if(judge(a[i],a[j],a[k])){
                    flag = 1;
                    ans = max(ans, (a[i] + a[j] + a[k])  * 1LL);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

int main() {
    code_by_jisam;
    int T = 1;
    cin >> T;
    while (T--) {
        solution();
    }
    return 0;
}